<?php

$mid = $_POST['mid'];

include "../config/database.php";

$con = mysqli_connect($dbhost,$dbuser,$dbpasswd,$dbname);

$sqlname = $dbprefix.'messages';

$sql = "SELECT * FROM `".$sqlname."` WHERE `id`=".$mid;

$sqli = "UPDATE `".$sqlname."` SET `status` = '0' WHERE `".$sqlname."`.`id` =".$mid;

#print $sqli;

$result = mysqli_query($con, $sql);
if (mysqli_num_rows($result) > 0) {
    while($row = mysqli_fetch_assoc($result)) {
        $data = array("mid" => $mid,'msg' => $row['msg']);
        $raw = array('code' => 0,"data" => $data);
        mysqli_query($con, $sqli);
    }
} else {
    $data = array("mid" => $mid);
    $raw = array('code' => 1,"data" => $data);
}

echo json_encode($raw , JSON_UNESCAPED_UNICODE)

?>